import { IProp, IWeapon } from "../Interface/State";
import { Singleton } from "../Singleton";
import { IEntityConfig, ISkillConfig, IWeaponConfig } from "../common/Config";
import { GEntity, GProp, GSelectPool, GSkill, GWeapon } from "../common/Global";
import { deepClone } from "../common/Util";

export class ConfigManager extends Singleton {
    static get Ins() {
        return super.GetInstance<ConfigManager>()
    }

    getWeaponCfg({ entityType, star }: IWeapon | { entityType: any, star: any }) {
        const key = entityType + '_' + star
        return this.getWeaponCfgById(key)
    }
    getWeaponCfgById(id: string): IWeaponConfig {
        return deepClone(GWeapon[id])
    }

    getPropCfg({ entityType, star }: IProp | { entityType: any, star: any }) {
        const key = entityType + '_' + star
        return GProp[key]
    }

    /** 获取选择池配置 */
    getSelectPoolCfg(id: number) {
        return GSelectPool[id]
    }

    /** 获取对象配置 */
    getEntityCfg(id: number): IEntityConfig {
        return GEntity[id]
    }

    /** 获取技能配置 */
    getSkillCfg(id: number): ISkillConfig {
        return GSkill[id]
    }
}